package com.example.qxfw.nyqx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.ny.SrvProductTemplate;
import com.example.qxfw.nyqx.mapper.SrvProductTemplateMapper;
import com.example.qxfw.nyqx.service.SrvProductTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SrvProductTemplateServiceImpl implements SrvProductTemplateService {

    @Autowired
    private SrvProductTemplateMapper srvProductTemplateMapper;

    @Override
    public List<SrvProductTemplate> getList(String templateType) {
        return srvProductTemplateMapper.getList(templateType);
    }

    @Override
    public List<SrvProductTemplate> getList1(String templateType, String templateName) {
        return srvProductTemplateMapper.selectList(Wrappers.<SrvProductTemplate>lambdaQuery()
                .eq(SrvProductTemplate::getTemplatetype,templateType)
                .eq(SrvProductTemplate::getTemplatename,templateName));
    }

    @Override
    public Integer save(SrvProductTemplate srvProductTemplate) {
        return srvProductTemplateMapper.insert(srvProductTemplate);
    }

    @Override
    public Integer delete(String templateType, String templateName) {
        return srvProductTemplateMapper.delete(Wrappers.<SrvProductTemplate>lambdaQuery()
                .eq(SrvProductTemplate::getTemplatetype,templateType)
                .eq(SrvProductTemplate::getTemplatename,templateName));
    }

    @Override
    public Integer update(SrvProductTemplate srvProductTemplate) {
        return srvProductTemplateMapper.update(srvProductTemplate,Wrappers.<SrvProductTemplate>lambdaUpdate()
                .eq(SrvProductTemplate::getTemplatetype,srvProductTemplate.getTemplatetype())
                .eq(SrvProductTemplate::getTemplatename,srvProductTemplate.getTemplatename()));
    }
}
